<?php
	session_start();
	mysql_connect("localhost", "sapmenet_admin", "a1s2d3f4g5h6j7") or die ("Problem with datebase");
	mysql_select_db("sapmenet_users");
	$albumID=$_POST['albumID'];
	$id=mysql_query("SELECT userID FROM albums WHERE ID={$albumID}");
	$id=mysql_result($id, 0);
	if ($id==$_SESSION['JID'])
	{
		$pic=mysql_query("SELECT put,id FROM pictures WHERE album='".$albumID."'");
		while($thePic = mysql_fetch_array($pic, MYSQL_NUM))
		{
			unlink($thePic[0]);
			mysql_query("DELETE FROM comments WHERE picID={$thePic[1]}");
		}
		
		mysql_query("DELETE FROM pictures WHERE album={$albumID}");
		mysql_query("DELETE FROM albums WHERE ID={$albumID}");
	}
?>